import { numberFormat } from "@/util/util.js";
export const tableOptionOffine = {
  border: true,
  index: true,
  indexLabel: "序号",
  stripe: true,
  menuAlign: "center",
  align: "center",
  menu: false,
  header: false,
  column: [
    {
      type: "input",
      label: "唯一标识",
      prop: "id",
      hide: true
    },
    {
      type: "input",
      label: "主表关联ID",
      prop: "relationId",
      hide: true
    },
    {
      type: "input",
      label: "车票类型",
      prop: "ticketType",
      hide: true
    },
    {
      type: "select",
      label: "车票名称",
      prop: "ticketName",
      width: 150,
      dicUrl: "/support/swpmticketcardtypeparam/dict/YXCP",
      cell: true,
      props: {
        label: "subName",
        value: "subEnName"
      },
      component: "ticket-select",
      params: {
        valueKey: "ticketPrice",
        unitKey: "ticketUnit"
      }
    },
    {
      type: "number",
      label: "票价",
      prop: "ticketPrice",
      precision: "2",
      //cell: true,
      formatter: (row, value, label, column) => {
        // return numberFormat(value, column.precision)
        return `${row.ticketPrice == null ? 0 : row.ticketPrice}`;
      }
    },
    {
      type: "number",
      label: "现金售卖张数",
      prop: "cashSellNum",
      cell: true
    },
    {
      type: "number",
      label: "现金售卖金额",
      prop: "cashSellAmount",
      precision: 2,
      formatter: (row, value, label, column) => {
        const ticketPrice = row.ticketPrice;
        const cashSellNum = row.cashSellNum;
        let money = 0;
        if (ticketPrice && cashSellNum) {
          money = ticketPrice * cashSellNum;
        }
        row.cashSellAmount = money;
        return numberFormat(money, column.precision);
      }
    },
    {
      type: "number",
      label: "支付宝售卖张数",
      prop: "alipaySellNum",
      cell: true
    },
    {
      type: "number",
      label: "支付宝售卖金额",
      prop: "alipaySellAmount",
      precision: 2,
      formatter: (row, value, label, column) => {
        const ticketPrice = row.ticketPrice;
        const alipaySellNum = row.alipaySellNum;
        let money = 0;
        if (ticketPrice && alipaySellNum) {
          money = ticketPrice * alipaySellNum;
        }
        row.alipaySellAmount = money;
        return numberFormat(money, column.precision);
      }
    },
    {
      type: "number",
      label: "微信售卖张数",
      prop: "wechatSellNum",
      cell: true
    },
    {
      type: "number",
      label: "微信售卖金额",
      prop: "wechatSellAmount",
      precision: 2,
      formatter: (row, value, label, column) => {
        const ticketPrice = row.ticketPrice;
        const wechatSellNum = row.wechatSellNum;
        let money = 0;
        if (ticketPrice && wechatSellNum) {
          money = ticketPrice * wechatSellNum;
        }
        row.wechatSellAmount = money;
        return numberFormat(money, column.precision);
      }
    },
    {
      type: "number",
      label: "合计张数",
      prop: "totalSellNum",
      formatter: (row, value, label, column) => {
        let sum = 0;
        const cashSellNum = isNaN(row.cashSellNum) ? 0 : row.cashSellNum;
        const alipaySellNum = isNaN(row.alipaySellNum) ? 0 : row.alipaySellNum;
        const wechatSellNum = isNaN(row.wechatSellNum) ? 0 : row.wechatSellNum;
        sum = cashSellNum + alipaySellNum + wechatSellNum;
        row.totalSellNum = sum;
        return numberFormat(sum);
      }
    },
    {
      type: "number",
      label: "合计金额",
      prop: "totalSellAmount",
      precision: 2,
      formatter: (row, value, label, column) => {
        let money = 0;
        const cashSellAmount = isNaN(row.cashSellAmount)
          ? 0
          : row.cashSellAmount;
        const alipaySellAmount = isNaN(row.alipaySellAmount)
          ? 0
          : row.alipaySellAmount;
        const wechatSellAmount = isNaN(row.wechatSellAmount)
          ? 0
          : row.wechatSellAmount;
        money = cashSellAmount + alipaySellAmount + wechatSellAmount;
        row.totalSellAmount = money;
        return numberFormat(money, column.precision);
      }
    },
    {
      type: "date",
      label: "售卖时间",
      prop: "sellTime",
      cell: true,
      width: 150,
      format: "yyyy-MM-dd",
      valueFormat: "yyyy-MM-dd"
    },
    {
      type: "input",
      label: "创建时间",
      prop: "createTime",
      hide: true
    },
    {
      type: "input",
      label: "数据更新时间",
      prop: "updateTime",
      hide: true
    },
    {
      type: "input",
      label: "删除标志 1：删除 0：未删",
      prop: "delFlag",
      hide: true
    }
  ]
};

export const tableOptionOffineView = {
  border: true,
  index: true,
  indexLabel: "序号",
  stripe: true,
  menuAlign: "center",
  align: "center",
  menu: false,
  header: false,
  column: [
    {
      type: "input",
      label: "唯一标识",
      prop: "id",
      hide: true
    },
    {
      type: "input",
      label: "主表关联ID",
      prop: "relationId",
      hide: true
    },
    {
      type: "input",
      label: "车票类型",
      prop: "ticketType",
      hide: true
    },
    {
      type: "select",
      label: "车票名称",
      prop: "ticketName",
      width: 150,
      dicUrl: "/support/swpmticketcardtypeparam/dictAll/YXCP",
      cell: false,
      props: {
        label: "subName",
        value: "subEnName"
      },
      component: "ticket-select",
      params: {
        valueKey: "ticketPrice",
        unitKey: "ticketUnit"
      }
    },
    {
      type: "number",
      label: "票价",
      prop: "ticketPrice",
      precision: "2",
      //cell: true,
      formatter: (row, value, label, column) => {
        // return numberFormat(value, column.precision)
        return `${row.ticketPrice == null ? 0 : row.ticketPrice}`;
      }
    },
    {
      type: "number",
      label: "现金售卖张数",
      prop: "cashSellNum",
      cell: true
    },
    {
      type: "number",
      label: "现金售卖金额",
      prop: "cashSellAmount",
      precision: 2,
      formatter: (row, value, label, column) => {
        const ticketPrice = row.ticketPrice;
        const cashSellNum = row.cashSellNum;
        let money = 0;
        if (ticketPrice && cashSellNum) {
          money = ticketPrice * cashSellNum;
        }
        row.cashSellAmount = money;
        return numberFormat(money, column.precision);
      }
    },
    {
      type: "number",
      label: "支付宝售卖张数",
      prop: "alipaySellNum",
      cell: true,
      hide: true
    },
    {
      type: "number",
      label: "支付宝售卖金额",
      prop: "alipaySellAmount",
      precision: 2,
      formatter: (row, value, label, column) => {
        const ticketPrice = row.ticketPrice;
        const alipaySellNum = row.alipaySellNum;
        let money = 0;
        if (ticketPrice && alipaySellNum) {
          money = ticketPrice * alipaySellNum;
        }
        row.alipaySellAmount = money;
        return numberFormat(money, column.precision);
      },
      hide: true
    },
    {
      type: "number",
      label: "微信售卖张数",
      prop: "wechatSellNum",
      cell: true,
      hide: true
    },
    {
      type: "number",
      label: "微信售卖金额",
      prop: "wechatSellAmount",
      precision: 2,
      formatter: (row, value, label, column) => {
        const ticketPrice = row.ticketPrice;
        const wechatSellNum = row.wechatSellNum;
        let money = 0;
        if (ticketPrice && wechatSellNum) {
          money = ticketPrice * wechatSellNum;
        }
        row.wechatSellAmount = money;
        return numberFormat(money, column.precision);
      },
      hide: true
    },
    {
      type: "number",
      label: "合计张数",
      prop: "totalSellNum",
      formatter: (row, value, label, column) => {
        let sum = 0;
        const cashSellNum = isNaN(row.cashSellNum) ? 0 : row.cashSellNum;
        const alipaySellNum = isNaN(row.alipaySellNum) ? 0 : row.alipaySellNum;
        const wechatSellNum = isNaN(row.wechatSellNum) ? 0 : row.wechatSellNum;
        sum = cashSellNum + alipaySellNum + wechatSellNum;
        row.totalSellNum = sum;
        return numberFormat(sum);
      }
    },
    {
      type: "number",
      label: "合计金额",
      prop: "totalSellAmount",
      precision: 2,
      formatter: (row, value, label, column) => {
        let money = 0;
        const cashSellAmount = isNaN(row.cashSellAmount)
          ? 0
          : row.cashSellAmount;
        const alipaySellAmount = isNaN(row.alipaySellAmount)
          ? 0
          : row.alipaySellAmount;
        const wechatSellAmount = isNaN(row.wechatSellAmount)
          ? 0
          : row.wechatSellAmount;
        money = cashSellAmount + alipaySellAmount + wechatSellAmount;
        row.totalSellAmount = money;
        return numberFormat(money, column.precision);
      }
    },
    {
      type: "date",
      label: "售卖时间",
      prop: "sellTime",
      cell: true,
      width: 150,
      format: "yyyy-MM-dd",
      valueFormat: "yyyy-MM-dd"
    },
    {
      type: "input",
      label: "创建时间",
      prop: "createTime",
      hide: true
    },
    {
      type: "input",
      label: "数据更新时间",
      prop: "updateTime",
      hide: true
    },
    {
      type: "input",
      label: "删除标志 1：删除 0：未删",
      prop: "delFlag",
      hide: true
    }
  ]
};
